//
//  HMAFNetworkTool.swift
//  Weibo
//
//  Created by xiongminghua on 16/7/19.
//  Copyright © 2016年 熊明华. All rights reserved.
//

import UIKit
import AFNetworking

/// 封装网络工具单例类

class HMAFNetworkTool: AFHTTPSessionManager {
    
    // 网络请求前面一段不会变化
    // https://api.weibo.com/2/statuses/friends_timeline.json
    // https://api.weibo.com/2/statuses/mentions/ids.json
    // https://api.weibo.com/2/favorites.json
    
    // Swift 中的单例
    static let sharedAFNetwork: HMAFNetworkTool = HMAFNetworkTool(baseURL: NSURL(string: "https://api.weibo.com/2/"))
    
    // 重写构造函数方法
    override init(baseURL url: NSURL?, sessionConfiguration configuration: NSURLSessionConfiguration?) {
        
        super.init(baseURL: url, sessionConfiguration: configuration)
        
        // 添加响应反序列化器支持的类型
        self.responseSerializer.acceptableContentTypes?.insert("text/plain")
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
 
}
